<?php


namespace app\admin\system\controller;


use app\admin\system\logic\AttachmentCategoryLogic;
use app\common\controller\BaseAdminController;
use support\utils\TreeUtil;

/**
 * 附件类型
 * Class AttachmentController
 * @package app\admin\system\controller
 */
class AttachmentCategoryController extends BaseAdminController
{
    protected $noNeedRight = ['*'];

    protected function init()
    {
        parent::init();
        $this->logic = new AttachmentCategoryLogic();
    }


    public function listTree()
    {
        $list = $this->logic->select()->toArray();
        array_walk($list, function (&$v) {
            $v['label'] = $v['name'];
            unset($v['name']);
        });
        $list = TreeUtil::getTree($list);
        return $this->success($list);
    }
}